

<template>
    <div class="appointment-projectbilling">
        <appointmentOverview
            ref="appointmentOverview"
            @actions="actions"
            v-show="page_i == 1"
        ></appointmentOverview>
        <!-- 预约的详情 -->
        <appointmentThree
            ref="appointmentThree"
            v-show="page_i == 2"
            :is_back="true"
            @backFun="backFun"
            @modificationFun="modificationFun"
        ></appointmentThree>
        <!-- 新建预约单 -->
        <appointmentAdd
            ref="appointmentAdd"
            v-show="page_i == 3"
            @backFun="backFun3"
            :page_i="page_i"
            :page_show_i="page_show_i"
			:is_back="true"
        ></appointmentAdd>
        <appointmentEditService
            ref="appointmentEditService"
            v-show="page_i == 4"
            @backFun="backFun"
        ></appointmentEditService>
    </div>
</template>
<script>
import appointmentOverview from "@/components/appointment/appointmentOverview.vue";
import appointmentThree from "@/components/appointment/appointmentThree.vue";
import appointmentAdd from "@/components/appointment/appointmentAdd.vue";
import appointmentEditService from "@/components/appointment/appointmentEditService.vue";

export default {
    components: {
        appointmentOverview,
        appointmentThree,
        appointmentAdd,
        appointmentEditService,
    },
    data() {
        return {
            page_i: 1,
            page_show_i: 1,
        };
    },
	onLoad() {
	},
    mounted() {
        this.initData();
    },
    methods: {
        initData() {
            this.$refs.appointmentOverview.getData();
        },
        backFun() {
            this.page_i = 1;
            this.$refs.appointmentOverview.getData();
        },
        backFun3(isEdit, id) {
            if (isEdit) {
                this.page_i = 2;
                this.$refs.appointmentThree.initData(id);
            } else {
                this.backFun();
            }
        },
        modificationFun(data) {
            this.page_i = 3;
            this.page_show_i = 3;
            this.$nextTick(() => {
                this.$refs.appointmentAdd.modificationFun(data);
            });
        },
        actions(data) {
			console.log("aaaaa");
            if (data.id) {
				console.log("aaaaa1",data);
                if (data.isStaffid) {
                    this.page_i = 4;
                    this.$nextTick(() => {
                        this.$refs.appointmentEditService.initData(data);
                    });
                } else {
                    if (data.isFill) {
                        this.page_i = 2;
                        const id = data.bookid;
                        this.$nextTick(() => {
                            this.$refs.appointmentThree.initData(id);
                        });
                    } else {
                        this.page_i = 3;
                        this.page_show_i = 3;
                        this.$nextTick(() => {
                            this.$refs.appointmentAdd.initData(data);
                        });
                    }
                }
            }
        },
    },
};
</script>

<style lang="scss" scoped>
</style>
